package notes.java.sjms23.s2_strategy;

// 环境类实现
public class Traveler {
	
	private TravelStrategy travelStrategy;
	
	// 设置策略
	public void setTravelStrategy(TravelStrategy travelStrategy) {
		this.travelStrategy = travelStrategy;
	}
	// 执行策略
	public void travelMode() {
		this.travelStrategy.travelMode();
	}
	
	public static void main(String[] args) {
		Traveler t = new Traveler();
		
		// 策略一：坐飞机
		//t.setTravelStrategy(new AirStrategy());
		// 策略二：:坐火车
		//t.setTravelStrategy(new TrainStrategy());
		// 策略三：坐汽车
		t.setTravelStrategy(new CarStrategy());
		
		t.travelMode();
	}

}
